<?php
/**
 * Created by PhpStorm.
 * User: lzy
 * Date: 2018/11/21
 * Time: 16:04
 */
namespace App\FreeBird\Controllers\Admin;
use App\Base\Controllers\Controller;
use App\FreeBird\Contracts\RebateLogInterface;
use Illuminate\Http\Request;

class RebateLogController extends Controller
{

    /**
     * 返佣列表
     * @return RebateLogInterface
     */
    public function getRebateLogInterface(){
        return app()->make(RebateLogInterface::class);
    }
    public function index(Request $request){
        if($request->getMethod()=='POST'){
            $where=function($query) use ($request){
                $username=$request->input("username");
                if(!empty($username)){
                    $query->where("username", "like", '%' . $username . '%');
                }

                $busername=$request->input("busername");
                if(!empty($busername)){
                    $query->where("busername", "like", '%' . $busername . '%');
                }
                $mountType=$request->input("mount_type");
                if(!empty($mountType)){
                    $query->where("mount_type",$mountType);
                }
                $type=$request->input("type");
                if(!empty($type)){
                    $query->where("type",$type);
                }
                $sourceType=$request->input("source_type");
                if(!empty($sourceType)){
                    $query->where("source_type",$sourceType);
                }
            };
            return  $this->getRebateLogInterface()->getList($where);
        }
        return view("freebird.rebate.index");
    }


}